package org.jeecg.modules.business.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.business.entity.BusDict;
import org.jeecg.modules.business.entity.BusDoorLock;
import org.jeecg.modules.business.mapper.BusDoorLockMapper;
import org.jeecg.modules.business.model.BusDictTreeModel;
import org.jeecg.modules.business.service.IBusDoorLockService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 门锁管理
 * @Author: jeecg-boot
 * @Date:   2023-03-20
 * @Version: V1.0
 */
@Service
public class BusDoorLockServiceImpl extends ServiceImpl<BusDoorLockMapper, BusDoorLock> implements IBusDoorLockService {

    @Override
    public boolean deleteByHotelId(String hotelId) {
        LambdaQueryWrapper<BusDoorLock> query = new LambdaQueryWrapper<BusDoorLock>();
        query.eq(BusDoorLock::getHotelId, hotelId);
        query.eq(BusDoorLock::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
//        List<BusDoorLock> list= this.list(query);
//        list.forEach(v -> {
//            v.setDelFlag(CommonConstant.DEL_FLAG_1);
//        });
//        boolean res = saveOrUpdateBatch(list);
        boolean res = remove(query);
        return res;
    }

    @Override
    public List<BusDoorLock> getByHotelId(String hotelId) {
        LambdaQueryWrapper<BusDoorLock> query = new LambdaQueryWrapper<BusDoorLock>();
        query.eq(BusDoorLock::getHotelId, hotelId);
        query.eq(BusDoorLock::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
        List<BusDoorLock> list= this.list(query);
        return list;
    }
}
